﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using AlumniProject.Framework;

namespace AlumniProject
{
    public partial class DangKyGiangVien : System.Web.UI.UserControl
    {
        TaiKhoanAccess _taikhoan = new TaiKhoanAccess();
        protected void Page_Load(object sender, EventArgs e)
        {

            var tinhthanh = _taikhoan.HocViFull();
            ddrHocVi.DataSource = tinhthanh;
            ddrHocVi.DataValueField = "MaHocVi";
            ddrHocVi.DataTextField = "TenHocVi";
            ddrHocVi.DataBind();
        }

        public string GetText()
        {
            return txtTenGV.Text;
        }
        protected void btnDangKyGV_Click(object sender, EventArgs e)
        {
            ButtonHoanTatClick(sender, e);
        }

        public event EventHandler ButtonHoanTatClick;
        public void dkGiangVien()
        {
            TaiKhoan tk = (TaiKhoan) Session["taikhoandk"];
            GiangVien gv = new GiangVien();

            gv.Ten = txtTenGV.Text;
            gv.HocVi = ddrHocVi.SelectedValue;
            gv.SDT = txtSoDTGV.Text;
            DateTime d;
            DateTime.TryParse(txtNgaySinhGV.Text, out d);
            gv.NgaySinh = d;

            bool res = _taikhoan.DangKyTaiKhoan(tk, "gv", gv, null);

            //Response.Write(res
            //    ? "<script>alert('Đăng ký thành công, chờ kiểm duyệt!');</script>"
            //    : "<script>alert('Đăng ký thất bại!');</script>");
        }
    }
}